﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Intranet.Models.activity>>" %>
<div id="myActivities">
    <% if (Model == null)
       {
    %>
    <h3>
        You have no activities!</h3>
    <%
       }
       else
       {%>
    <table>
        <tr>
            <th>
                details
            </th>
            <th>
            </th>
        </tr>
        <%
           foreach (var item in Model.Where(p=>!p.parentId.HasValue))
           {
               if (DateTime.Compare(item.dueDate, DateTime.Now) < 0)
               {
        %>
        <tr class="warning">
            <%
               }
               else
               {
            %>
            <tr class="nowarning">
                <%
               }
                %>
                <td class="clickable" onclick="document.location='<%=Url.Action("ActivityDetails",new {id=item.id}) %>'">
                    <%: Html.DisplayFor(modelItem => item.details)%>
                </td>
                <td class="controls rightAlign">
                    <%: Ajax.ActionLink("Delete", "Delete", new { id = item.id }, new AjaxOptions { UpdateTargetId = "myActivities", InsertionMode = InsertionMode.Replace })%>
                </td>
            </tr>
            <% if (item.activities1.Count > 0)
               {
                   Html.RenderPartial("MyActivities", item.activities1);                   
               }
           }
       } %>
    </table>
</div>
